package br.com.character.flex.chorm.core.sql
{
    import mx.collections.ArrayCollection;
    
    [Bindable]
    public class From implements IFrom
    {
        private var _tables:ArrayCollection;
        
        public function From(t:ArrayCollection)
        {
            _tables = t;
        }
        
        public function get tables():ArrayCollection
        {
            return _tables;
        }
        
        public function set tables(param:ArrayCollection):void
        {
            _tables = param;
        }
        
        public function add(param:ITable):void{
            if(tables!=null){
                tables.addItem(param);
            }    
        }
        
        public function toSQL():String {
            var result:String = " from ";
            for (var i:int = 0; i < tables.length; i++) {
                result += tables.getItemIndex(i);
                if(tables.length < i){
                    result += ",";
                }
            }
            return result;
        }
    }
}